const orderModel = require("../models/order_model");



function getorder(goods, onRetGot, onErrGot) {
    orderModel.selectorder(goods, (ret) => onRetGot({ret,code:200,total:""}), (err) => onErrGot({ err ,code:400}));
    
}


function getall(goods, onRetGot, onErrGot) {
    orderModel.selectall(goods, (ret) => onRetGot({ret,code:200,total:""}), (err) => onErrGot({ err ,code:400}));
    
}
function getselect(goods, onRetGot, onErrGot) {
    orderModel.selectstate(goods, (ret) => onRetGot({ret,code:200,total:""}), (err) => onErrGot({ err ,code:400}));
    
}

function addorder(goods, onRetGot, onErrGot) {
    console.log("goods2",goods);
    orderModel.addorder(goods,(ret)=>onRetGot({ret,code:200}),(err)=>onErrGot({err,code:400}))
}

function deleteorder(goods, onRetGot, onErrGot) {
    orderModel.deleteorder(goods, (ret) => onRetGot({ret,code:200}), (err) => onErrGot({ err ,code:400}));
    
}

function updateorder(goods, onRetGot, onErrGot) {
    console.log(goods);
    orderModel.updateorder(goods, (ret) => onRetGot({ret,code:200}), (err) => onErrGot({ err ,code:400}));
    
}


const userController = {
    getall,
    getorder,
    deleteorder,
    addorder,
    updateorder,
    getselect
    
};
module.exports = userController;